# coding=utf-8
class Solution:
    def longestPalindrome(self, s: str) -> str:
        maxl = 0
        maxlen = 0
        n = len(s)
        for i in range(n):
            l = 0
            for j in range(i + 1):
                if i - l >= 0 and i + l < n:
                    if s[i - l] == s[i + l]:
                        l += 1
                        if l > maxlen:
                            maxlen = l
                            maxl = i
        jishu = s[maxl - maxlen + 1:maxl + maxlen]
        oumaxl=0
        oumaxlen = 0
        for i in range(n-1):
            j = i + 1
            if s[i] == s[j]:
                l = 0
                for x in range(i + 1):
                    if i - l >= 0 and j + l < n:
                        if s[i - l] == s[j + l]:
                            l += 1
                            if l + 1 > oumaxlen:
                                oumaxlen = l
                                oumaxl = i
                                # print(maxlen, maxl)
        # print(maxl - maxlen + 1, maxl + maxlen)
        oushu = s[oumaxl - oumaxlen + 1:oumaxl + oumaxlen+1]
        # print(jishu)
        # print(oushu)
        if len(jishu)>len(oushu):
            return jishu
        else:
            return oushu


a = Solution()

vv = a.longestPalindrome('jfoxbgqkcytrmdggkagdkvghakvgweskvhgdmggakfbayufmabcdefgfedcbasoxbghwlvxgeksfjbsdfbshgsdbfshgfuieefjisdbfcuysgfuwebhsdfhisu')
print(vv)
